package com.im.users.controller;

import com.im.common.utils.R;
import com.im.security.annotation.LoginUser;
import com.im.security.dto.LoginVo;
import com.im.users.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @auther Zeng
 * @date 2023/7/10 - 11:02
 * @Version 1.0
 */

@RestController
@RequestMapping("/login")
@Slf4j
public class LoginController {

    @Autowired
    public UserService loginService;

    @PostMapping("/codeLogin")
    public R login(@RequestBody Map map) throws Exception {
        System.out.println("LoginController.login");
        R result = loginService.login(map);
        return result;
    }

    @PostMapping("/updateLoginTime")
    public R updateLoginTime(@RequestBody Map map, @LoginUser LoginVo loginVo) {
        log.debug("updateLoginTime:loginVo:{}",loginVo);
        System.out.println("map = " + map);
        R result = loginService.updateLoginTime(map);
        return result;
    }
}
